package com.yoso.constants;

import javax.xml.crypto.Data;
import java.util.*;

/**
 * @author shizejin
 * @date 2021/11/2
 * @description:
 */
public enum Day {
    DAY("每天",""),

    WEEK1("每周","周一"),
    WEEK2("每周","周二"),
    WEEK3("每周","周三"),
    WEEK4("每周","周四"),
    WEEK5("每周","周五"),
    WEEK6("每周","第x个"),
    WEEK7("每周","最后一个"),

    MONTH("每月","第x个"),
    ;



    private String x;
    private String y;
    private static final Map<String, String> map = new HashMap<String, String>();
    Day(String x, String y) {
        this.x = x;
        this.y = y;
    }

    Day() {
    }

    public String getX() {
        return x;
    }

    public void setX(String x) {
        this.x = x;
    }

    public String getY() {
        return y;
    }

    public void setY(String y) {
        this.y = y;
    }

    static {
        for (Day day : Day.values()) {
            map.put(day.getX(), day.getY());
        }
    }

    // 根据name查询value的集合
    public static Set<String> getValuesByKey(String name) {
        Set<String> list = new LinkedHashSet<>();
        for (Day value : Day.values()) {
            if (value.getX().equals(name)){
                list.add(value.getY());
            }
        }
        return list;
    }
//    查询name的集合
    public static Set<String> keys(){
        Set<String> set = new LinkedHashSet<>();
        for (Day day : Day.values()) {
            set.add(day.getX());
        }
        return set;
    }
//    获取级联下拉列表
    public static Map<String,Set<String>> list(){
        Map<String,Set<String>> map = new LinkedHashMap<>();
        for (String key : keys()) {
            map.put(key,getValuesByKey(key));
        }
        return map;
    }

}
